package org.bdware.irs;

import org.bdware.irs.backend.Application;
import org.bdware.irs.server.http.GrsMain;
import org.bdware.irs.server.http.IrsMain;
import org.bdware.irs.server.tcp.GrsServerMain;
import org.bdware.irs.server.tcp.IrpServerMain;

public class IrsBootWithTcp {
    /*
    启动前需要先启动IRSMockMain
    Spring boot的代码在WebService/controller，controller为http入口
 */


    public static String configFilePath = "irsConfig.json";
    public static IrsConfig irsConfig;


    public static void main(String[] args) {

        if(args.length>0){
            configFilePath = args[0];
        }

        irsConfig = IrsConfig.loadFromConfigFile(configFilePath);

        if(irsConfig.grsEnabled) {
            new Thread(() -> {
                try {
                    GrsServerMain.main(args);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();
        }
        new Thread(() -> {
            try {
                IrpServerMain.main(args);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();

        try {
            Thread.sleep(2*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(() ->  Application.main(args)).start();
    }
}

